home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / CTools 2.2.1d / CTools / CTools.rsrc / TEXT_152_Clean-Up.txt < prev    next >
Encoding:
Text File  |  1995-12-01  |  3.2 KB  |  48 lines

  1. Cleaning It Up:
  2.  
  3. Now that you‚Äôve got the routines ‚Äúpopping up all over the place‚Äù, you must handle any other things which will prevent CTools‚Ñ¢ C Source Formatter from giving a clean output, which is the next goal of editing.  The reason you do this now is because it takes care of a few things which would become compiler errors, and it makes the C source (it‚Äôs not Pascal any more) easier to read and follow.
  4.  
  5. These preventers are:
  6.  
  7. (1) Last right paren (')') missing from the end of a do-while loop.
  8. (2) Improper or absent switch components (i.e. no ‚Äúcase ‚Äú or ‚Äúbreak;‚Äù).
  9. (3) No end-of-line semicolon (;) before "else" keywords.
  10.  
  11. For the "do-while" in CMaster‚Ñ¢, you simply find "while" and using the up/down selection search function to find them.  Start at the top of the file, click the down button, if it is a "while" at the end of a do/while loop, hit Command leftArrow, then rightArrow once and type a ')' there.  If there are comments on the line, you must manually place the insertion point.  Do this until EOF or it wraps back to the first one.  If you don‚Äôt have CMaster‚Ñ¢ use Command G and the left/right arrows as above.
  12.  
  13. Improper switch components are no "case " before the cases, no "break;" between the cases commas where ":RETURNcase " should go.  If you have KodeKeys, you've been "saved" from a monotonous, drudgery.  Use my KodeKeys macro set for these (does one intermediate comma).
  14.  
  15. Use Find to find the first occurrence of the word "switch" in your CTools‚Ñ¢ output.  In CMaster‚Ñ¢, get that word into the selection search queue.  You can see that the word "case " is missing from the switch components.  Put them there.
  16.  
  17. With my macros, you simply put the insertion point before the first one and type "ctrl[3]" (control key, numeric pad 3).
  18.  
  19. Move down to where the next "case " goes, type "break;", hit RETURN twice and type "case " again.
  20.  
  21. With my KodeKeys macros, simply put the insertion point where "case " goes and type "ctrl-option-[3]" (control, option, numeric pad 3).  It's automagically and correctly updated.
  22.  
  23. If there are two case possibilities, with a comma, like:
  24.  
  25. keyDown, autoKey:
  26.  
  27. then hit "ctrl-shift-[3]" using the KodeKeys macros.  It will turn the above into:
  28.  
  29. break;
  30.  
  31. case keyDown:
  32. case autoKey:
  33.  
  34. in one shot!
  35.  
  36. Otherwise, just type in "case " and a space and replace the comma with a ':' and return and another "case" and space, so that it looks like the above example.
  37.  
  38. When you get down to the last one, you type "break" after it.  The macro for that is "ctrl[2]" alone.
  39.  
  40. It may be that break; does not belong there.  Maybe it has return, instead.  Determine this as you go.
  41.  
  42. Lastly, find all else with CMaster‚Äôs selection/search function and add a ‚Äò;‚Äô to the end of the previous code line (where they are missing).
  43.  
  44. Now, if you are in a big merged file, format the source later - after a complete compile and you‚Äôve split the files back up into their individual .c files.  On a single file, run the CTools‚Ñ¢ C Source Formatter now, to sort out the appearance.  This editing step will not make the source proper for the compiler, but will make it easier and ready to edit for compilation.
  45.  
  46. Be sure not to feed the formatter too big a chuck of code to format at one time.
  47.  
  48.